<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单完成 - MAN商城</title>
    <link rel="stylesheet" href="css/style.css">
    <style>
        .order-complete-container {
            max-width: 800px;
            margin: 50px auto;
            padding: 30px;
            background-color: white;
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            text-align: center;
        }
        .success-icon {
            font-size: 72px;
            color: #4CAF50;
            margin-bottom: 20px;
        }
        .order-info {
            margin: 30px 0;
            padding: 20px;
            background-color: #f9f9f9;
            border-radius: 5px;
            text-align: left;
        }
        .order-info p {
            margin: 10px 0;
        }
        .action-buttons {
            margin-top: 30px;
        }
        .btn {
            display: inline-block;
            padding: 12px 30px;
            margin: 0 10px;
            background-color: #ff6700;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            transition: background-color 0.3s;
        }
        .btn:hover {
            background-color: #e55c00;
        }
        .btn-secondary {
            background-color: #666;
        }
        .btn-secondary:hover {
            background-color: #555;
        }
    </style>
</head>
<body>
    <header class="header">
        <!-- 同首页的头部 -->
    </header>

    <main class="order-complete-container">
        <div class="success-icon">✓</div>
        <h2>订单提交成功！</h2>
        <p>感谢您的购买，我们已收到您的订单</p>
        
        <div class="order-info" id="orderInfo">
            <!-- 订单信息将通过JavaScript动态加载 -->
        </div>
        
        <div class="action-buttons">
            <a href="user/orders.html" class="btn">查看订单</a>
            <a href="index.html" class="btn btn-secondary">继续购物</a>
        </div>
    </main>

    <footer class="footer">
        <!-- 同首页的页脚 -->
    </footer>

    <script src="js/utils.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 从URL获取订单ID
            const urlParams = new URLSearchParams(window.location.search);
            const orderId = urlParams.get('id');
            
            if (!orderId) {
                window.location.href = 'index.html';
                return;
            }
            
            // 获取订单信息
            const orders = JSON.parse(localStorage.getItem('orders')) || [];
            const order = orders.find(o => o.id.toString() === orderId);
            
            if (!order) {
                window.location.href = 'index.html';
                return;
            }
            
            // 显示订单信息
            const orderInfo = document.getElementById('orderInfo');
            orderInfo.innerHTML = `
                <p><strong>订单编号：</strong> ${order.id}</p>
                <p><strong>下单时间：</strong> ${order.date}</p>
                <p><strong>订单金额：</strong> ¥${order.total.toFixed(2)}</p>
                <p><strong>支付方式：</strong> ${getPaymentMethodName(order.paymentMethod)}</p>
                <p><strong>收货信息：</strong> ${order.shippingInfo.name} ${order.shippingInfo.phone} ${order.shippingInfo.address}</p>
            `;
        });
        
        function getPaymentMethodName(method) {
            switch(method) {
                case 'alipay': return '支付宝';
                case 'wechat': return '微信支付';
                case 'bank': return '银行卡';
                default: return '其他';
            }
        }
    </script>
</body>
</html>